/*
 *   Copyright 2012, Thomas Kerber
 *
 *   Licensed under the Apache License, Version 2.0 (the "License");
 *   you may not use this file except in compliance with the License.
 *   You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 *   Unless required by applicable law or agreed to in writing, software
 *   distributed under the License is distributed on an "AS IS" BASIS,
 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *   See the License for the specific language governing permissions and
 *   limitations under the License.
 */
package milk.skimmed;

import java.io.File;
import java.io.IOException;
import java.util.List;

/**
 * Instructions for extracting a mod.
 * 
 * This interface may be implemented by any mod, in a class named
 * 
 * "milk_extract<<Unique name here>>.class" and placed in the mods root
 * directory. These instructions are then used in extraction.
 * @author Thomas Kerber
 * @version 1.0.0
 */
public interface ExtractionInstructions{
    
    /**
     * Initializes. All available data is passed on right away; This method
     * may be used to precalculate the output of the other methods.
     * 
     * It is guaranteed that the values passed here are the same as in the
     * other methods.
     * @param extractFrom The directory to extract from.
     * @param minecraftRoot The root directory of minecraft.
     * @param availableJarps The jarps available.
     * @param origName The original The original name of the mod file.
     * @throws IOException 
     */
    public void init(File extractFrom, File minecraftRoot,
            List<Jarp> availableJarps, String origName) throws IOException;
    
    /**
     * Extracts files.
     * 
     * Generally speaking, if you can just copy it over, do it here.
     * @param extractFrom The directory to extract from.
     * @param minecraftRoot Minecrafts root directory.
     * @throws IOException
     */
    public void extractFiles(File extractFrom, File minecraftRoot)
            throws IOException;
    
    /**
     * Extracts jarps.
     * @param extractFrom The directory to extract from.
     * @return An array of files pointing to jarp files to extract.
     * @throws IOException
     */
    public File[] extractJarps(File extractFrom) throws IOException;
    
    /**
     * Extracts not-yet-created jarps.
     * 
     * (Extract information required to create said jarps)
     * @param extractFrom The directory to extract from.
     * @param availableJarps The jarps available.
     * @return The creation info for any and all to-be jarps.
     * @throws IOException
     */
    public JarpCreationInfo[] extractClassRoots(File extractFrom,
            List<Jarp> availableJarps) throws IOException;
    
    /**
     * Performs closing operations, if necessary.
     * @throws IOException
     */
    public void close() throws IOException;
    
}
